/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package xmarti.vacaxm.action;

import java.util.List;
import xmarti.vacaxm.beans.maintenance.AnimalCode;
import xmarti.vacaxm.beans.maintenance.AnimalFilter;
import xmarti.vacaxm.beans.maintenance.Area;
import xmarti.vacaxm.beans.maintenance.Breed;
import xmarti.vacaxm.beans.maintenance.Bull;
import xmarti.vacaxm.beans.maintenance.Calf;
import xmarti.vacaxm.beans.maintenance.Country;
import xmarti.vacaxm.beans.maintenance.Cow;
import xmarti.vacaxm.exception.ExceptionHibernateVacaxm;
import xmarti.vacaxm.model.ModelMaintenance;

/**
 *
 * @author xmarti
 */
public class ImplMaintenance  {
    private ModelMaintenance model;
  
    public ImplMaintenance() {
        
            model= new ModelMaintenance();
  
    }
    
    public List<Country> getCountries() throws ExceptionHibernateVacaxm {
       return  model.getListCountries();
    }
    public List<Breed> getBreeds() throws ExceptionHibernateVacaxm {
       return  model.getListBreeds();
    }
    public List<Area> getAreas() throws ExceptionHibernateVacaxm {
        return model.getListAreas();
    }
    public List<Bull> getBulls() throws ExceptionHibernateVacaxm {        
        return model.getListAnimal(Bull.class);        
       
    }
    public List<Cow> getCows() throws ExceptionHibernateVacaxm {        
        return model.getListAnimal(Cow.class);                                    
    }
    public List<Calf> getCalfs() throws ExceptionHibernateVacaxm {        
        return model.getListAnimal(Calf.class);                                    
    }
    public List<Bull> getBullsActive(AnimalFilter f) throws ExceptionHibernateVacaxm {        
        return model.getListAnimalActive(Bull.class,f);        
       
    }
    public List<Cow> getCowsActive(AnimalFilter f) throws ExceptionHibernateVacaxm {        
        return model.getListAnimalActive(Cow.class,f);                                            
    }
    public List<Calf> getCalfsActive(AnimalFilter f,String gender) throws ExceptionHibernateVacaxm {        
        return model.getListAnimalActive(Calf.class,f,gender);                                    
    }
    public List<Bull> getBullsNOActive() throws ExceptionHibernateVacaxm {        
        return model.getListAnimalNOActive(Bull.class);               
    }
    
    
    public List<Cow> getCowsNOActive() throws ExceptionHibernateVacaxm {        
        return model.getListAnimalNOActive(Cow.class);                                    
    }
    public List<Calf> getCalfsNOActive() throws ExceptionHibernateVacaxm {        
        return model.getListAnimalNOActive(Calf.class);                                    
    }
    public Cow getCow(int id) throws ExceptionHibernateVacaxm{
        return model.getObjectById(id, Cow.class);
    }
    
    public Bull getBull(int id) throws ExceptionHibernateVacaxm{
        return model.getObjectById(id, Bull.class);
    }
    public boolean existAnimalCode(AnimalCode animalCode) throws ExceptionHibernateVacaxm{
        AnimalCode c=model.getByAnimalCode(animalCode);
        return animalCode.equals(c);
    }
    public boolean update (Object animal) throws ExceptionHibernateVacaxm{       
        return model.update(animal);
    }
    public boolean add (Object animal) throws ExceptionHibernateVacaxm{       
        return model.add(animal);
    }
    public int add (Breed object) throws ExceptionHibernateVacaxm{       
        return model.add(object);
    }
    public int add (Country object) throws ExceptionHibernateVacaxm{       
        return model.add(object);
    }
    public int add (Area object) throws ExceptionHibernateVacaxm{       
        return model.add(object);
    }
    public boolean delete(Object object) throws ExceptionHibernateVacaxm{
        return model.delete(object);
    }
    public long getNumberAnimals(Class entityClass ){
        return model.getNumberAnimalsActive(entityClass);
    }
    public long getNumberAnimals(Class entityClass, String gender ){
        return model.getNumberAnimalsActive(entityClass, gender);
    }
    
}
